<div class="nav4">
    <nav>
        <div id="nav4_ul" class="nav_4">
            <ul class="box">
            <foreach name="menu['dataset']" item="me">
                <li>
                <if condition="$me['subNav']"> 
                    <a href="javascript:;" class=""><span>{$me.showtitle}</span></a>
                    <dl>
                        <foreach name="me.subNav" item="vo">
                        <dd><a href="{$vo.link}"><span>{$vo.showtitle}</span></a></dd>
                        </foreach>
                    </dl>
                <else/>
                    <a href="{$me.link}" class=""><span>{$me.showtitle}</span></a>
                </if>
                </li>
            </foreach>
            </ul>
        </div>
    </nav>
    <div id="nav4_masklayer" class="masklayer_div on">&nbsp;</div>
</div>
<script type="text/javascript">
    var nav4 =(function(){
        bindClick = function(els, mask){
            if(!els || !els.length){return;}
            var isMobile = "ontouchstart" in window;
            for(var i=0,ci; ci = els[i]; i++){
                ci.addEventListener("click", evtFn, false);
            }

            function evtFn(evt, ci){
                ci =this;
                for(var j=0,cj; cj = els[j]; j++){
                    if(cj != ci){
                        console.log(cj);
                        cj.classList.remove("on");
                    }
                }
                if(ci == mask){mask.classList.remove("on");return;}
                switch(evt.type){
                    case "click":
                        var on = ci.classList.toggle("on");
                        mask.classList[on?"add":"remove"]("on");
                        break;
                }
            }
            mask.addEventListener(isMobile?"touchstart":"click", evtFn, false);
        }
        return {"bindClick":bindClick};
    })();
    nav4.bindClick(
        document.getElementById("nav4_ul").querySelectorAll("li>a"), 
        document.getElementById("nav4_masklayer")
    );
</script>